#ifndef MSG_H
#define MSG_H

#include "PobTran.h"

#define MANUAL_POS_DEBIT_ENTRY_CODE		"011"
#define SWIPE_POS_DEBIT_ENTRY_CODE		"021"
#define MANUAL_POS_ENTRY_CODE			"012"
#define SWIPE_POS_ENTRY_CODE			"022"



typedef struct {
	unsigned char ISOMap[33];  
	

	unsigned char discard[201];	 /* Variable to dump unwanted data into  */

	unsigned char tpdu [11];	 /* Transport_Protocol_Data_Unit         */
	unsigned char message_id [5];

	unsigned char field_02 [20]; /* Primary_Account_Number               */
	unsigned char field_03 [7];  /* Processing_Code                      */
	unsigned char field_04 [13]; /* Amount_Transaction                   */
	unsigned char field_05 [13]; /* Amount_Settlement                    */
	//* skip 06                  /* Amount_Cardholder_Billing            */
	unsigned char field_07 [11]; /* Transmission_Date_and_Time           */
	//* skip 08                  /* Amount_Cardholder_Billing_Fee        */
	unsigned char field_09 [9];  /* Conversion_Rate_Settlement           */
	//* skip 10                  /* Conversion_Rate_Cardholder_Billing   */
	unsigned char field_11[7];   /* Systems_Trace_Audit_Number           */
	unsigned char field_12[7];   /* Time_Local_Transaction               */
	unsigned char field_13[5];   /* Date_Local_Transaction               */
	unsigned char field_14[5];   /* Date_Expiration                      */
	//* skip 15                  /* Date_Settlement                      */
	unsigned char field_16[5];   /* Date_Conversion                      */
	unsigned char field_17[5];   /* Date_Capture                         */
	//* skip 18                  /* Merchants_Type                       */
	unsigned char field_19[4];   /* Acquiring_Institution_Country_Code   */
	unsigned char field_20[4];   /* Primary_Account_Number_Extended_Country_Code*/
	unsigned char field_21[4];   /* Forwarding_Institution_Country_Code  */
	unsigned char field_22[4];   /* Point_of_Service_Entry_Mode          */
	unsigned char field_23[4];   /* Card_Sequence_Number                 */
	unsigned char field_24[4];   /* Network_International_Identifier     */
	unsigned char field_25[3];   /* Point_of_Service_Condition_Code      */
	unsigned char field_26[3];   /* Point_of_Service_PIN_Capture_Code    */
	unsigned char field_27[2];   /* Authorization_Identification_Response_Length*/
	unsigned char field_28[9];   /* Amount_Transaction_Fee               */
	unsigned char field_29[9];   /* Amount_Settlement_Fee                */
	//* skip 30                  /* Amount_Transaction_Processing_Fee    */
	//* skip 31                  /* Amount_Settlement_Processing_Fee     */
	unsigned char field_32[12];  /* Acquiring_Institution_ID_Code        */
	unsigned char field_33[12];  /* Forwarding_Institution_ID_Code       */
	unsigned char field_34[29];  /* Primary_Account_Number_Extended      */
	unsigned char field_35[38];  /* Track_2_Data                         */
	//* skip 36                  /* Track_3_Data                         */
	unsigned char field_37[13];  /* Retrieval_Reference_Number           */
	unsigned char field_38[7];   /* Authorization_Identification_Response*/
	unsigned char field_39[3];   /* Response_Code                        */
	//* skip 40                  /* Service_Restriction_Code             */
	unsigned char field_41[9];   /* Card_Acceptor_Terminal_Identification*/
	unsigned char field_42[16];  /* Card_Acceptor_Identification_Code    */
	unsigned char field_43[41];  /* Card_Acceptor_Name_Location          */
	unsigned char field_44[26];  /* Card_Acceptor_Name_Location          */
	//* skip 45                  /* Track_1_Data                         */
	//* skip 46                  /* Additional_Data_ISO                  */
	//* skip 47                  /* Additional_Data_National             */
	//* skip 48                  /* Additional_Data_Private              */
	unsigned char field_48[1000];/* Currency_Code_Transaction            */
	unsigned char field_49[4];   /* Currency_Code_Transaction            */
	unsigned char field_50[4];   /* Currency_Code_Settlement             */
	//* skip 51                  /* Currency_Code_Cardholder_Billing     */
	unsigned char field_52[9];   /* Personal_Identification_Number_Data  */
	//* skip 53                  /* Security_Related_Control_Information */
	unsigned char field_54[100]; /* Additional_Amounts                   */
	//* skip 55..59 */
	unsigned char field_60[100]; /* Example of one variant field         */
	unsigned char field_61[100];
	//* skip 61..63 */
	unsigned char field_62[11];
	unsigned char field_63[100];
	unsigned char field_64[9];   /* Message_Authentication_Code_Field    */
	//* skip 65..70 */
	unsigned char field_71[5];   /* Message number                       */
	unsigned char field_72[5];   /* Message number last                  */
	//* skip 73..79 */
	unsigned char field_80[11];  /* Inquiries number                     */
	unsigned char field_81[11];  /* Authorizations number                */
	//* skip 82..134 */
	unsigned char field_135[5];  /* test field */
	unsigned char field_136[5];  /* test field */
	//* skip 137..143 */
	unsigned char field_144[11]; /* test field */
	unsigned char field_145[11]; /* test field */
} Message_Struct;


int PackMessage(TRANSACTION_OBJECT *pobTran, unsigned char *SentBuff);
int UnpackAndValidateMessage(TRANSACTION_OBJECT *pobTran, unsigned char *RecvBuff);
int inDisplayHostResponse(TRANSACTION_OBJECT *pobTran);

int SetBitmap(TRANSACTION_OBJECT *pobTran);

#define HOST_ID			"HOST.ID"
#define HOST_TERMINAL	"HOST.TERMINAL"

#endif